#include "AssignDecoyOrSniperState.h"
#include "MoveToDecoyPrePositionState.h"
#include "MoveSniperIntoPositionState.h"

bool AssignDecoyOrSniperState::decoyAssigned = false;

AssignDecoyOrSniperState::AssignDecoyOrSniperState(void)
{
}


AssignDecoyOrSniperState::~AssignDecoyOrSniperState(void)
{
}

Command AssignDecoyOrSniperState::GetCommand(MultiAgent* agent) {
	// First tank in position becomes the decoy
	if (!AssignDecoyOrSniperState::decoyAssigned) {
		AssignDecoyOrSniperState::decoyAssigned = true;

		agent->setState(new MoveToDecoyPrePositionState());
		return agent->GetCommand();
	}
	else if(MoveToDecoyPrePositionState::IsDecoyManeuvaring()) {
		agent->setState(new MoveSniperIntoPositionState());
		return agent->GetCommand();
	}

	// if we couldn't assign the tank to be the sniper or the decoy
	// just wait until the decoy is in position.
	return Command(agent->getTank()->index, 0, 0, false);
}